package Portlet;

import com.medpro.testengine.core.CommandsList;
import util.Validation;


public class PolicyForm {

    CommandsList command;
    Validation validation;

    public PolicyForm(CommandsList commander) {
        command = commander;
        validation = new Validation(commander);
    }

    public PolicyForm checkPolicyForm() {

        command.verifyElementPresent("requestPolicyForm")
                .verifyElementPresent("requestPopup")
                .verifyElementPresent("button.close")
                .verifyElementPresent("msg.PolisyForm1")
                .verifyElementPresent("rF.PolicyNamber")
                .verifyElementPresent("rF.PolicyNamberInput")
                .verifyElementPresent("rF.PolicyEDateName")
                .verifyElementPresent("rf.PolicyEDateSelect")
                .verifyElementPresent("rf.Submit")
                .verifyElementPresent("rf.Cancel")
        ;
        validation.validationPolicy("rF.PolicyNamberInput")
        ;
        return this;
    }


    public PolicyForm checkPolicyTable() {

        command.clearTypeSubmit("rF.PolicyNamberInput", "760250")
                .verifyElementPresent("rf.PT.Name")
                .verifyElementPresent("rf.PolicyTable")
                .verifyElementPresent("rf.PT.Header1")
                .verifyElementPresent("rf.PT.Header2")
                .verifyElementPresent("rf.PT.Header3")
                .verifyElementPresent("rf.PT.Header4")
                .verifyElementPresent("rf.PT.Content1")
                .verifyElementPresent("rf.PT.Content2")
                .verifyElementPresent("rf.PT.Content3")
                .verifyElementPresent("rf.PT.Content4")
                .verifyElementPresent("rf.SelectDate")
                .verifyElementPresent("rF.PolicyEDateName")
                .verifyElementPresent("rf.PolicyEDateSelect")
                .verifyElementPresent("ref.SelectDateContent1")
                .verifyElementPresent("ref.SelectDateContent2")
        ;
        return this;
    }

    public PolicyForm chekPolicyEmail() {

        command.select("rf.PolicyEDateSelect", "05/15/2012")
                .verifyElementPresent("rf.EmailForm")
                .verifyElementPresent("rf.EmailMsg")
                .verifyElementPresent("rf.EmailName")
                .verifyElementPresent("rf.EmailInput")
        ;
        return this;
    }

    public PolicyForm returnToHomePage(String url) {
        command.open(url)
                .click("msg.clickHere")
                .clearTypeSubmit("rF.PolicyNamberInput", "760250")
        ;
        return this;
    }

    public PolicyForm checkPolicyEmailValidation() {

        command.click("msg.clickHere")
                .clearTypeSubmit("rF.PolicyNamberInput", "760250")
                .select("rf.PolicyEDateSelect", "05/15/2012");
        validation.validationEmail("rf.EmailInput");

        return this;
    }

    public PolicyForm chekPolicyNotificationEmail() {

        command.select("rf.PolicyEDateSelect", "05/15/2013")
                .verifyElementPresent("rf.NotifEmailForm")
                .verifyElementPresent("rf.NotifEmailMsg")
                .verifyElementPresent("rf.NotifEmailSelect")
        ;
        return this;
    }

    public PolicyForm checkAllEmail() {

        command.select("rf.PolicyEDateSelect", "05/15/2012")
                .select("rf.PolicyEDateSelect", "05/15/2013")
                .verifyElementPresent("rf.EmailForm")
                .verifyElementPresent("rf.EmailMsg")
                .verifyElementPresent("rf.EmailName")
                .verifyElementPresent("rf.EmailInput")
                .verifyElementPresent("rf.NotifEmailForm")
                .verifyElementPresent("rf.NotifEmailMsg")
                .verifyElementPresent("rf.NotifEmailSelect")
        ;
        return this;
    }

    public PolicyForm policySubmit() {

        command.click("rf.Submit")
                .verifyElementPresent("rf.SubmitedForm")
                .verifyElementPresent("sf.msg1")
                .verifyElementPresent("sf.msg2")
                .verifyElementPresent("sf.msg3")
                .click("sf.OK")
        ;
        return this;
    }

}
